package LeetCode.leetcode;

/**
 * 3的幂
 * @author: leiwenkang02@meituan.com
 * @date: 2018/8/23
 * @time: 17:35
 */
public class Test326三的幂 {
    public static void main(String[] args) {
        System.out.println(isPowerOfThree(27));
    }

    public static boolean isPowerOfThree(int n) {
        if (n <= 0) {
            return false;
        }
        while (n != 1) {
            if (n % 3 != 0) {
                return false;
            } else {
                n = n / 3;
            }
        }
        return true;
    }
}
